package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.DevFileDao;
import com.sugon.entity.DevFileEntity;
import com.sugon.service.DevFileService;
import com.sugon.utils.Constant;
import com.sugon.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 设备图片信息Service实现类
 *
 * @author sugon
 * @date 2019-11-28 17:06:44
 */
@Service("devFileService")
public class DevFileServiceImpl implements DevFileService {
    @Autowired
    private DevFileDao devFileDao;

    /**
     * queryObject
     *
     * @param id 主键
     * @return
     */
    @Override
    public DevFileEntity queryObject(String id) {
        return devFileDao.queryObject(id);
    }

    /**
     * queryList
     *
     * @param map 参数
     * @return
     */
    @Override
    public List<DevFileEntity> queryList(Map<String, Object> map) {
        return devFileDao.queryList(map);
    }

    /**
     * queryTotal
     *
     * @param map 参数
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return devFileDao.queryTotal(map);
    }

    /**
     * save
     *
     * @param devFile 实体
     * @return
     */
    @Override
    public int save(DevFileEntity devFile) {
        devFile.setId(RandomUtil.randomString(32));
        devFile.setCreateDate(DateUtil.date());
        devFile.setCreateUser(ShiroUtils.getUserId());
        devFile.setDelFlag(Integer.valueOf(Constant.IS_NOT_DEL));
        return devFileDao.save(devFile);
    }

    /**
     * update
     *
     * @param devFile 实体
     * @return
     */
    @Override
    public int update(DevFileEntity devFile) {
        devFile.setUpdateDate(new Date());
        devFile.setUpdateUser(ShiroUtils.getUserId());
        return devFileDao.update(devFile);
    }

    /**
     * delete
     *
     * @param id
     * @return
     */
    @Override
    public int delete(String id) {
        return devFileDao.delete(id);
    }

    /**
     * deleteBatch
     *
     * @param ids
     * @return
     */
    @Override
    public int deleteBatch(String[] ids) {
        return devFileDao.deleteBatch(ids);
    }
}
